home *** CD-ROM | disk | FTP | other *** search
- Path: newsfeed.internetmci.com!xmission!news
- From: tknarr@xmission.com ( Todd Knarr )
- Newsgroups: comp.lang.c++,comp.lang.c
- Subject: Re: Performance: C vs. C++
- Date: 27 Jan 1996 04:22:47 GMT
- Organization: Chaos Central
- Message-ID: <4ec9an$ui@news.xmission.com>
- References: <30F6BAAC.12B5@iastate.edu> <4da9pn$a45@news.bridge.net> <4dnpl2$c8g@classic.iinet.com.au> <3105E9DC.1BE3@enermet.fi> <DLr46y.7rH@txnews.amd.com>
- Reply-To: tknarr@xmission.com ( Todd Knarr )
- NNTP-Posting-Host: slc48.xmission.com
- X-Newsreader: IBM NewsReader/2 v1.2
-
- In <DLr46y.7rH@txnews.amd.com>, Bret Patterson <faustus> writes:
- >Big deal. So c++ does a virtual table lookup, but in order for C to have this ability
- >it has to use a switch statement or ifelse construct. I would say with good compiler
- >optimization C++ is going to be faster and more readable.
-
- With a good compiler, you may not even need the table lookup for a virtual
- function. The lookup is needed only when the call is through a pointer or
- reference >and< the actual type cannot be determined at compile time. For
- things like local variables accessed through pointers, the compiler should
- be able to optimize away the vtable lookup completely, reducing those
- virtual function calls to non-virtual ones.
-
- If it doesn't, then you start hacking the code to reduce the overhead.
-
- --
- Todd Knarr : tknarr@xmission.com | finger for PGP public key
- | Member, USENET Cabal
-
- Seriously, I don't want to die just yet. I don't care how
- good-looking they are, I! don't! want! to! die!"
- -- Megazone ( UF1 )
-
-